<?php
namespace Store\Controller;
// +----------------------------------------------------------------------
// | TAODUDU.COM  [ Simple Efficient Excellent ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.taodudu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: ubten <462193409@qq.com> http://www.ubten.com/
// +----------------------------------------------------------------------
use Think\Controller;

class LoginController extends Controller{
    
    public function  index(){
        layout(FALSE);
        $this->display();
    }
    

    public function do_login() {
        $username = I('post.username');
        //判断用户输入的是用户名，或手机号，或邮箱
        $password = I('post.password');

        $forward = I('forward');
        if (empty($forward)) {
            $forward = U('Index/index');
        }

        $users = D('Users');
        $res = $users->login($username, $password, 2);
        if ($res) {
            //用户若设置自动登陆则session过期时间改为7天
            //$remember = I('post.remember');
            $this->success('尊敬的' . session('user_auth.username') . ' 欢迎您来到淘嘟嘟商城!', $forward);
        }
    }
    
    
    public function loginOut(){
        session('store_id',NULL);
        session('store_name',NULL);
        session('store_auth',NULL);
        redirect(U('Login/index'));
    }
    
    
}
